﻿using System;

class ZeroSubsetSum
{
    static int counter = 0;

    static void Main()
    {
        Console.WriteLine("How many number you will input?");
        int number = int.Parse(Console.ReadLine());
        int[] array = new int[number];

        for (int i = 0; i < array.Length; i++)
        {
            Console.WriteLine("Number {0} is:",i+1);
            array[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine("What is the sum of subsets?");
        int n = int.Parse(Console.ReadLine());
        
        for (int i = 1; i <= array.Length; i++)
        {
            int[] result = new int[i];
            Generator(array, 0, result, 0, n);
        }
        Console.WriteLine("There is precicely {0} subsets which sum is {1}!!! ", counter, n);
    }

    static void Generator(int[] array, int index, int[] result, int start, int n)
    {
        if (result.Length != index)
        {
            for (int i = start; i < array.Length; i++)
            {
                result[index] = array[i];
                Generator(array, index + 1, result, i + 1, n);
            }
        }
        else
        {
            Print(result, n);
        }
    }
    static void Print(int[] array, int n)
    {
        int sum = 0;
        for (int i = 0; i < array.Length - 1; i++)
        {
            Console.Write(array[i] + "+");
            sum = sum + array[i];
        }
        Console.Write(array[array.Length - 1] + "=");
        sum = sum + array[array.Length - 1];
        Console.WriteLine(sum);
        if (sum == n)
        {
            counter++;
        }
    }
}